package nix.dao.impl;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.springframework.orm.hibernate5.HibernateCallback;

import nix.dao.CustomerDao;
import nix.domain.Customer;

public class CustomerDaoImpl extends BaseDaoImpl<Customer> implements CustomerDao {

	@Override
	public List<Object[]> getIndustryCount() {
		
		return getHibernateTemplate().execute(new HibernateCallback<List>() {

			@Override
			public List<Object[]> doInHibernate(Session session) throws HibernateException {

				SQLQuery query = session.createSQLQuery("select d.dict_item_name,count(*) total from cst_customer c,base_dict d " +
						"where c.cust_industry = d.dict_id and d.dict_type_code = '001' " +
						"group by d.dict_item_name order by total desc;");
				return query.list();
			}
		});
	}

}
